package com.nowcoder.community.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nowcoder.community.entity.LoginTicket;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface LoginTicketMapper extends BaseMapper<LoginTicket> {
    default LoginTicket selectByTicket(String ticket) {
        return BaseMapper.super.selectOne(new QueryWrapper<LoginTicket>() {
            { eq("ticket", ticket); }
        });
    }

    @Update("UPDATE login_ticket SET status = #{status} WHERE ticket = #{ticket}")
    void updateStatus(String ticket, int status);
}
